package numybxb

import (
	"fmt"
	"math"
	"unsafe"
)

// 定义程序的入口
func TestNum() {
	// 定义数字类型
	var a uint8 = 4
	var b uint16 = 4
	var c uint32 = 4
	var d uint64 = 4
	var e = 4 // 默认是int类型

	fmt.Printf("变量a：%T, 值是:%v \n", a, a)
	fmt.Printf("变量b：%T, 值是:%v \n", b, b)
	fmt.Printf("变量c：%T, 值是:%v \n", c, c)
	fmt.Printf("变量d：%T, 值是:%v \n", d, d)
	fmt.Printf("变量e：%T, 值是:%v \n", e, e) // 默认是int类型

	fmt.Printf("变量e占用的字节数：%d \n", unsafe.Sizeof(e)) // 打印占用多少个内存空间

	fmt.Printf("int的最小值是：%d\n", math.MinInt)
	fmt.Printf("int的最大值是：%d\n", math.MaxInt)
	fmt.Printf("int64的最小值是：%d\n", math.MinInt64)
	fmt.Printf("int64的最大值是：%d\n", math.MaxInt64)
}

func TestInt() {
	var abc int = 12                                    // 默认是int类型。int类型等价于int64
	fmt.Printf("变量abc占用的字节数：%d \n", unsafe.Sizeof(abc)) // 占8个字节
	fmt.Printf("int的最小值是：%d\n", math.MinInt)            // -9223372036854775808
	fmt.Printf("int的最大值是：%d\n", math.MaxInt)            // 9223372036854775807
}
